#!/usr/bin/env python
# $Id$

from page import page
import sys, time, urllib
import db 

class add(page):

	def __init__(self):
		page.__init__(self)
		self.headingstr = "Reports"
		self.db1 = db.db()
		self.upcdb1 = db.upcdb()

	def render(self):
		self.logic()
		self.encoding()
		self.html()

	def logic(self):
		if request.has_key("cancel"):
			raise HTTP_REDIRECTION, "menu.py"

	def form(self):
		form = """
		<form name=add method=get action=reports.py>
		<table style="text-align: left; width: 20%;" border="1" cellpadding="3" cellspacing="0">
		<tbody>
		<tr>
			<td><a href=item_detail.py>Item Detail</a></td>
		</tr>
		<tr>
			<td><a href=percent_of_goal.py>Percent of Goal by Category</a></td>
		</tr>
		<tr>
			<td><a href=expiring_items.py>Expiring Items</a></td>
		</tr>
		<tr>
			<td><a href=shopping_list_start_form.py>Shopping List</a></td>
		</tr>
		</tbody>
		</table>
		<br />
		<input type=submit name=cancel value="Menu">
		</form>
		""" 
		print form

	def message(self):
		if request.has_key("m"):
			message = request["m"][0]
			if message:
				print message

	def body(self):
		self.start_body()
		self.heading()
		self.form()
		self.message()
		self.footer()
		self.end_body()

class runner:
	def _test(self):
		add().render()

	def _doctest(self):
		import doctest
		doctest.testmod()

if __name__ == "__main__":
	r = runner()
	getattr(r, "_"+sys.argv[1])()
else:
	add().render()
